package org.hibernate.impl;

import java.io.Serializable;
import java.sql.Connection;
import java.util.Map;
import java.util.Set;

import javax.naming.NamingException;
import javax.naming.Reference;

import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.SessionFactory;
import org.hibernate.StatelessSession;
import org.hibernate.cfg.ExtendedAnnotationConfiguration;
import org.hibernate.classic.Session;
import org.hibernate.engine.FilterDefinition;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.stat.Statistics;

public abstract class SessionFactoryWrapper implements SessionFactory {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	
	private SessionFactory realSessionFactory;
	private ExtendedAnnotationConfiguration config;
	
	protected SessionFactory getRealSessionFactory() {
		return realSessionFactory;
	}
	protected void setRealSessionFactory(SessionFactory realSessionFactory) {
		this.realSessionFactory = realSessionFactory;
	}
	
//	public SessionFactoryWrapper(SessionFactory sessionFactory){
//		this.realSessionFactory=sessionFactory;
//	}
	
	/**
	 * 
	 */
	public SessionFactoryWrapper(ExtendedAnnotationConfiguration config) {
		assert(config!=null);
		this.config=config;
	}
	
	
	@Override
	public void close() throws HibernateException {
		realSessionFactory.close();
	}

	@Override
	public void evict(Class persistentClass) throws HibernateException {
		realSessionFactory.evict(persistentClass);
	}

	@Override
	public void evict(Class persistentClass, Serializable id)
			throws HibernateException {
		realSessionFactory.evict(persistentClass, id);
	}

	@Override
	public void evictCollection(String roleName) throws HibernateException {
		realSessionFactory.evictCollection(roleName);

	}

	@Override
	public void evictCollection(String roleName, Serializable id)
			throws HibernateException {
		realSessionFactory.evictCollection(roleName, id);
	}

	@Override
	public void evictEntity(String entityName) throws HibernateException {
		realSessionFactory.evictEntity(entityName);
	}

	@Override
	public void evictEntity(String entityName, Serializable id)
			throws HibernateException {
		realSessionFactory.evictEntity(entityName, id);
	}

	@Override
	public void evictQueries() throws HibernateException {
		realSessionFactory.evictQueries();

	}

	@Override
	public void evictQueries(String cacheRegion) throws HibernateException {
		realSessionFactory.evictQueries(cacheRegion);
	}

	@Override
	public Map getAllClassMetadata() throws HibernateException {
		return realSessionFactory.getAllClassMetadata(); 
	}

	@Override
	public Map getAllCollectionMetadata() throws HibernateException {
		return realSessionFactory.getAllCollectionMetadata();
	}

	@Override
	public ClassMetadata getClassMetadata(Class persistentClass)
			throws HibernateException {
		return realSessionFactory.getClassMetadata(persistentClass);
	}

	@Override
	public ClassMetadata getClassMetadata(String entityName)
			throws HibernateException {
		return realSessionFactory.getClassMetadata(entityName);
	}

	@Override
	public CollectionMetadata getCollectionMetadata(String roleName)
			throws HibernateException {
		return realSessionFactory.getCollectionMetadata(roleName);
	}

	@Override
	public Session getCurrentSession() throws HibernateException {
		return realSessionFactory.getCurrentSession();
	}

	@Override
	public Set getDefinedFilterNames() {
		return realSessionFactory.getDefinedFilterNames();
	}

	@Override
	public FilterDefinition getFilterDefinition(String filterName)
			throws HibernateException {
		return realSessionFactory.getFilterDefinition(filterName);
	}

	@Override
	public Statistics getStatistics() {
		return realSessionFactory.getStatistics();
	}

	@Override
	public boolean isClosed() {
		return realSessionFactory.isClosed();
	}

	@Override
	public Session openSession() throws HibernateException {
		return realSessionFactory.openSession();
	}

	@Override
	public Session openSession(Connection connection) {
		return realSessionFactory.openSession(connection);
	}

	@Override
	public Session openSession(Interceptor interceptor)
			throws HibernateException {
		return realSessionFactory.openSession(interceptor);
	}

	@Override
	public Session openSession(Connection connection, Interceptor interceptor) {
		return realSessionFactory.openSession(connection, interceptor);
	}

	@Override
	public StatelessSession openStatelessSession() {
		return realSessionFactory.openStatelessSession();
	}

	@Override
	public StatelessSession openStatelessSession(Connection connection) {
		return realSessionFactory.openStatelessSession(connection);
	}

	@Override
	public Reference getReference() throws NamingException {
		return realSessionFactory.getReference();
	}

}
